<%@page import="forms.*, java.util.*" %>

<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ page import="javax.sql.*, model.*"%>

<%@ page isELIgnored ="false" %> 

<html:html>
<body>

<font size="6">Applications</font>
<p>
<a href="/CSE135_Project_struts/login/invalidate.jsp">Log out.</a>
<p>
	
	<%
	RowSet crsAppPage = (RowSet) request.getAttribute("crsAppPage");
	// RowSet crsAvgGrade = (RowSet) request.getAttribute("crsAvgGrade");
	

        // Iterate over the ResultSet
       	while (crsAppPage.next() ) {
        %>
		<table>
        <tr>
            <td>
                <%=crsAppPage.getString("first_name")%> <%=crsAppPage.getString("middle_initial")%> <%=crsAppPage.getString("last_name")%>
               
            </td>
            <td>
                <%=ReviewerModel.getAvgGrade(crsAppPage.getInt("application"))%>
               
            </td>
            <td>
            	<b><%=crsAppPage.getString("arp")%></b>
            </td>
            <td>
            	<html:form method="post" action="/changeStatus">
					<html:hidden property="appid" value="<%=Integer.toString(crsAppPage.getInt(\"application\"))%>" />
            	<%
            	if (crsAppPage.getString("arp").equals("Pending")){
            		%>
            		<button type="submit" name="ARP" value="Admit">Admit</button>
            		<button type="submit" name="ARP" value="Reject">Reject</button>
            	<%}
            	else if (crsAppPage.getString("arp").equals("Admit")){
            		%>
            		<button type="submit" name="ARP" value="Reject">Reject</button>
            		<button type="submit" name="ARP" value="Pending">Pending</button>
            	<%}
            	else{%>
 					<button type="submit" name="ARP" value="Admit">Admit</button>
            		<button type="submit" name="ARP" value="Pending">Pending</button>
            	<%} %>
            	</html:form>
            </td>
        </tr>
        </table>
        
        <% 
        }
        %>
	

</body>
</html:html>